home *** CD-ROM | disk | FTP | other *** search
- /* read.c --- p 502 */
- #include <stdio.h>
- #include <io.h>
- #include <fcntl.h>
- static char bigbuffer[60000];
- main()
- {
- int fhandle;
- int bytes_read;
- /* Open the file "autoexec.bat." Note that we need two '\' */
- if ( (fhandle = open("c:autoexec.bat", O_RDONLY)) == -1)
- {
- printf("open failed");
- exit(1);
- }
- printf("Attempting to read 60000 bytes from c:autoexec.bat:\n");
- if ((bytes_read = read(fhandle, bigbuffer, 60000)) == -1)
- {
- perror("read error");
- exit(1);
- }
- printf("only %u bytes read. Here's what was read:\n", bytes_read);
- write(1, bigbuffer, bytes_read);
- }